<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        canvas{
            border: 1px solid #1100cc;
        }
    </style>
</head>
<body>
    <canvas id='c1' width="600" height="400">
        浏览器不支持canvas
    </canvas>
    <script>
        /** @type {HTMLCanvasElement}**/
        var c1 = document.getElementById('c1')
        if(!c1.getContext){
            console.log('浏览器不支持')
        }
        var ctx = c1.getContext('2d')

        
        ctx.fillStyle="rgba(255,0,0,1)";
        ctx.fillRect(300,200,100,100);
        ctx.globalCompositeOperation ="source-out";
        ctx.fillStyle="rgba(0,0,255,1)";
        ctx.fillRect(350,250,100,100);
    </script>
</body>
</html>